package com.alan.dfs.rest;

import com.ace.cache.annotation.CacheClear;
import com.alan.dfs.msg.RestResponse;
import com.alan.dfs.service.ZoneFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("zone")
@Api(tags = "文件管理中心")
public class FileController {
    @Autowired
    ZoneFileService zoneFileService;

    @ApiOperation("公有文件列表")
    @GetMapping(value = "pubFiles")
    public RestResponse pubFiles(){
        return RestResponse.ok(zoneFileService.getFileList("avocado"));
    }

    @ApiOperation("私有文件列表---信纸")
    @GetMapping(value = "priPaperFiles")
    public RestResponse priPaperFiles(){
        return RestResponse.ok(zoneFileService.getFileList("grape"));
    }

    @ApiOperation("私有文件列表---素材")
    @GetMapping(value = "priMaterialFiles")
    public RestResponse priMaterialFiles(){
        return RestResponse.ok(zoneFileService.getFileList("sardine"));
    }

    @ApiOperation("清除文件缓存")
    @DeleteMapping(value = "files")
    @CacheClear(pre = "dfs:files")
    public RestResponse clearCache(){
        return RestResponse.ok("清除文件缓存成功！");
    }
}
